<!DOCTYPE html>
<html lang="zh_CN">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>悦听音乐app</title>
    <style>
        body,
        ul,
        dl,
        dd {
            margin: 0px;
            padding: 0px;
        }

        .wrap {
            position: fixed;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background: url('img/bg.jpg') no-repeat;
            background-size: 100% 100%;
        }

        .play_wrap {
            width: 800px;
            height: 544px;
            position: fixed;
            left: 50%;
            top: 50%;
            margin-left: -400px;
            margin-top: -272px;
            /* background-color: #f9f9f9; */
        }

        .search_bar {
            height: 60px;
            background-color: #1eacda;
            overflow: hidden;
            border-top-left-radius: 4px;
            border-top-right-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            position: relative;
            z-index: 11;
        }

        .search_bar img {
            margin-left: 23px;
        }

        .search_bar input {
            margin-right: 23px;
            width: 296px;
            height: 34px;
            border-radius: 17px;
            border: 0px;
            background: url('') 265px center no-repeat rgba(255, 255, 255, 0.45);
            text-indent: 15px;
            outline: none;
        }

        .search-icon {
            position: absolute;
            right: 35px;
            cursor: pointer;
        }

        .center_con {
            height: 435px;
            background-color: rgba(255, 255, 255, 0.5);
            display: flex;
        }

        .song_wrapper {
            width: 200px;
            height: 435px;
            box-sizing: border-box;
            padding: 10px;
            list-style: none;
            background: url('img/line.png') right center no-repeat;
            position: relative;
            overflow: hidden;
        }

        .song_list li {
            font-size: 12px;
            color: #333;
            line-height: 36px;
            width: 180px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            cursor: pointer;
        }

        .song_list li span {
            width: 20px;
            height: 20px;
            float: right;
            margin-right: 10px;
            margin-top: 10px;
        }

        .song_list .active {
            color: #da651e;
        }

        .player_con {
            width: 400px;
            height: 435px;
            position: relative;
        }

        .disc {
            position: absolute;
            left: 73px;
            top: 60px;
            z-index: 9;
        }

        .cover {
            position: absolute;
            left: 125px;
            top: 112px;
            width: 150px;
            height: 150px;
            border-radius: 75px;
            z-index: 8;
        }

        .comment_list {
            width: 200px;
            height: 435px;
            box-sizing: border-box;
            padding: 10px;
            list-style: none;
            background: url('img/line.png') left center no-repeat;
            overflow: hidden;
            position: relative;
        }

        .comment_list dl {
            padding-left: 55px;
            position: relative;
            margin-bottom: 20px;
        }

        .comment_list dt {
            position: absolute;
            left: 4px;
            top: 0px;
        }

        .comment_list dt img {
            width: 40px;
            height: 40px;
            border-radius: 20px;
        }

        .comment_list dd {
            font-size: 12px;
        }

        .comment_list .name {
            font-weight: bold;
            color: #333;
            margin-top: 5px;
        }

        .comment_list .detail {
            color: #666;
            margin-top: 5px;
            line-height: 18px;
        }

        .audio_con {
            height: 50px;
            background-color: #f1f3f4;
            border-bottom-left-radius: 4px;
            border-bottom-right-radius: 4px;
        }

        .myaudio {
            width: 800px;
            height: 40px;
            margin-top: 5px;
            outline: none;
            background-color: #f1f3f4;
        }

        /* 旋转的动画 */
        @keyframes Rotate {
            from {
                transform: rotateZ(0);
            }

            to {
                transform: rotateZ(360deg);
            }
        }

        /* 旋转的类名 */
        .autoRotate {
            animation-name: Rotate;
            animation-iteration-count: infinite;
            animation-play-state: paused;
            animation-timing-function: linear;
            animation-duration: 5s;
        }

        /* 是否正在播放 */
        .playing {
            animation-play-state: running;
        }

        .play_bar {
            position: absolute;
            left: 200px;
            top: -10px;
            z-index: 10;
            transform: rotate(-25deg);
            transform-origin: 12px 12px;
            transition: 1s;
        }

        /* 播放杆 转回去 */
        .play_bar.playing {
            transform: rotate(0);
        }

        .video_con {
            width: 600px;
            height: 444px;
            position: fixed;
            left: 20%;
            top: 20%;
            margin-left: -400px;
            margin-top: -272px;
            z-index: 100;
        }

        .video_con video {
            width: 800px;
            height: 504px;
            position: fixed;
            left: 50%;
            top: 50%;
            margin-left: -400px;
            margin-top: -272px;
            z-index: 100;
        }

        .video_con .mask {
            width: 1680px;
            height: 1080px;
            z-index: 99;
        }
    </style>
</head>

<body>
    <div class="wrap" id="app">
        <div class="play_wrap" id="player">
            <!-- 顶部歌曲搜索 -->
            <div class="search_bar">
                <img src="img/player_title.png" alt="" />
                <!-- 搜索输入框 -->
                <input type="text" v-model="query" @keyup.enter="searchMusic" placeholder="请输入你想听的歌曲" />
                <!-- 搜索按钮 -->
                <img src="img/zoom.png" class="search-icon" alt="" />
            </div>
            <!-- 中间部分，歌曲播放整个面板 -->
            <div class="center_con">
                <!-- 歌曲列表 -->
                <div class="song_wrapper">
                    <ul class="song_list">
                        <li v-for="item in musicList">
                            <a href="javascript:;"></a>
                            <b @click="playMusic(item.id)">{{ item.name }}</b>
                            <span v-if="item.mvid!=0" @click="playMv(item.mvid)"><img src="img/mv.png" alt=""></span>
                        </li>

                    </ul>
                </div>
                <!-- 歌曲播放 -->
                <div class="player_con">
                    <!-- 播放触杆 -->
                    <img src=" img/player_bar.png" class="play_bar  " :class="{playing:isPlaying}" />
                    <!-- 黑胶碟片 -->
                    <img src="img/disc.png" class="disc autoRotate " :class="{playing:isPlaying}" />
                    <!-- 歌曲封面 -->
                    <img :src="musicCover" class="cover autoRotate " :class="{playing:isPlaying}" />
                </div>
                <!-- 歌曲评论 -->
                <div class="comment_list">
                    <div>
                        <dl v-for="item in hotComments">
                            <dt><img :src="item.user.avatarUrl" alt="" /></dt>
                            <dd class="name">{{ item.nackname }}</dd>
                            <dd class="detail">{{item.content}}</dd>
                        </dl>
                    </div>
                </div>
            </div>
            <!-- 底部歌曲播放 -->
            <div class="audio_con">
                <audio :src="musicUrl" @play="play" @pause="pause" controls="controls" autoplay="autoplay" loop="loop"
                    class="myaudio"></audio>
            </div>
            <!-- mv播放 -->
            <div class="video_con" v-show="isShow" style="display: none;">
                <video :src="mvUrl" controls="control"></video>
                <div class="mask" @click="hide"></div>
            </div>
        </div>
    </div>


    <!-- 开发环境版本 -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <!-- 官方提供的 axios 在线地址 -->
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script>
        /*
        1.歌曲搜索接口
            请求地址：https://autumnfish.cn/search
            请求方法：get
            请求参数：keywords(查询关键字)
        */
        /*
         2.歌曲url获取接口
             请求地址：https://autumnfish.cn/song/url
             请求方式:get
             请求参数：id(查询关键字)
             响应内容:歌曲url地址
        */
        /*
          3.歌曲详情获取
              请求地址：https://autumnfish.cn/song/detail
              请求方式:get
              请求参数：ids(歌曲id)
              响应内容:歌曲详情(包括封面信息)
         */
        /*
         4.歌曲评论
              请求地址：https://autumnfish.cn/comment/hot?type=0
              请求方式:get
              请求参数：ids(歌曲id,地址中的type固定为0)
              响应内容:歌曲的热门评论
         */
        /*
         5.mv地址获取
              请求地址：https://autumnfish.cn/mv/url
              请求方式:get
              请求参数：ids(mvid,为0表示没有mv)
              响应内容:mv的地址
         */
        var app = new Vue({
            el: "#app",
            data: {
                query: "",
                // 歌曲列表
                musicList: [],
                // 歌曲地址
                musicUrl: "",
                // 歌曲封面
                musicCover: "",
                // 歌曲评论
                hotComments: [],
                //动画效果状态
                isPlaying: false,
                // 遮罩层的显示状态
                isShow: false,
                // mv地址
                mvUrl: ""

            },
            methods: {
                searchMusic: function () {
                    var that = this;
                    axios.get("https://autumnfish.cn/search?keywords=" + this.query)
                        .then(
                            function (response) {
                                // console.log(response)
                                // console.log(response.data.result.songs)
                                that.musicList = response.data.result.songs;
                            },
                            function (err) { }
                        )
                },
                playMusic: function (musicId) {
                    // console.log(456789);
                    var that = this;
                    // 歌曲播放
                    axios.get("https://autumnfish.cn/song/url?id=" + musicId)
                        .then(function (response) {
                            // console.log(response)
                            // console.log(response.data.data[0].url)
                            that.musicUrl = response.data.data[0].url;
                        }, function (err) { })
                    // 歌曲详情获取
                    axios.get("https://autumnfish.cn/song/detail?ids=" + musicId)
                        .then(function (response) {
                            // console.log(response)
                            that.musicCover = response.data.songs[0].al.picUrl;
                        }, function (err) { })
                    // 获取歌评论
                    axios.get("https://autumnfish.cn/comment/hot?type=0&id=" + musicId)
                        .then(function (response) {
                            console.log(response.data.hotComments)
                            that.hotComments = response.data.hotComments;
                        }, function (err) { })
                },
                play: function () {
                    // console.log("play");
                    this.isPlaying = true;
                },
                pause: function () {
                    // console.log("pause");
                    this.isPlaying = false;
                },
                playMv: function (mvid) {
                    var that = this;
                    axios.get("https://autumnfish.cn/mv/url?id=" + mvid)
                        .then(function (response) {
                            // console.log(respones.data.data.url);
                            that.isShow = true;
                            that.mvUrl = response.data.data.url;
                        }, function (err) { })
                },
                hide: function () {
                    this.isShow = false;
                }
            }
        })
    </script>
</body>

</html>